Removal of corrosive water-soluble salts, particularly chlorides of sodium and potassium from crude oil is an important processing operation in refining of crude oils. The process of desalting usually involves addition of 1 to 20 weight percent wash water to the crude oil, mixing to form a water-in-crude oil emulsion and then subjecting the water-in-crude oil emulsion to electrostatic demulsification or hydrocyclone treatment. Under the influence of electrostatic or centrifugal fields the dispersed water droplets coalesce and the water-in-oil emulsion is demulsified. Water and the water-soluble salts are separated from the crude oil and removed. Key to the efficiency of the desalting process is the formation of unstable water-in-oil emulsions. Most heavy crude oils that contain asphaltenes and naphthenic acids tend to form stable water-in-oil emulsions. These stable water-in-oil emulsions are difficult to demulsify and tend to form large volumes of a rag layer in the separator vessels. Rag layers are layers of water-in-oil emulsions and sub-micron size solids that form at the boundary between oil and water layers in separators. Formation of rag layers result in substantial oil loss and reduce the efficiency of dewatering and desalting processes. Current methods using centrifuges, hydrocyclones and electrostatic demulsifiers require large doses of demulsifier chemicals, high operation temperature and long residence times to desalt and/or dewater these water-in-oil emulsions. Thus, there is a continuing need for improved cost effective methods to demulsify and desalt water-in-oil emulsions especially those formed from heavy crude oils. Further, there is a need to predict the ability of a heavy crude oil to form stable emulsions so that preventive measures can be undertaken prior to wash water addition and formation of water-in oil emulsions. The present invention addresses these needs.